//package com.fitbet.api.web.controller.trading;
//
//import javax.servlet.http.HttpServletRequest;
//
//import org.apache.commons.lang3.StringUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.http.MediaType;
//import org.springframework.stereotype.Controller;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestMethod;
//import org.springframework.web.bind.annotation.RequestParam;
//import org.springframework.web.bind.annotation.ResponseBody;
//
//import com.demo2do.core.entity.result.HttpResult;
//import com.fitbet.api.service.SalesOrderService;
//import com.fitbet.api.service.UserBetService;
//import com.fitbet.api.web.controller.resolver.Secure;
//import com.fitbet.entity.bet.UserBet;
//import com.fitbet.entity.bet.UserBetStatus;
//import com.fitbet.entity.trading.OrderType;
//import com.fitbet.entity.trading.SalesOrder;
//import com.fitbet.entity.user.User;
//
///**
// * 
// * @author mohanlan
// *
// */
//@Controller
//@RequestMapping("/shopping")
//public class ShoppingController {
//    
//    @Autowired
//    private SalesOrderService salesOrderService;
//    
//    @Autowired
//    private UserBetService userBetService;
//    
//    /**
//     * 竞猜/投注 支付准备页
//     * 
//     * @return
//     */
//    @RequestMapping(value = "/prepare", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    public @ResponseBody HttpResult prepare(@Secure User user,
//                                @RequestParam("id") Long id,
//                                @RequestParam(name = "type", required = false, defaultValue = "bet") String type,
//                                @RequestParam(name = "userBetId", required = false) Long userBetId,
//                                @RequestParam(name = "support", required = false, defaultValue = "true") boolean support,
//                                HttpServletRequest request) {
//        
//        HttpResult httpResult = new HttpResult();
//        
//        if(StringUtils.equalsIgnoreCase(type, "bet")) {
//            // 当前可报名的期数
//            httpResult.success().data("betId", id);
//        } else {
//            UserBet userBet = userBetService.loadUserBet(id, new UserBetStatus[]{UserBetStatus.PROCESSING, UserBetStatus.PAID, UserBetStatus.OPEN, UserBetStatus.OPENFAILED, UserBetStatus.CLOSE, UserBetStatus.CLOSEFAILED});
//            httpResult.success().data("userBet", userBet)
//                                .data("bet", userBet.getBet())
//                                .data("supportId", id)
//                                .data("support", support);
//        }
//        httpResult.data("user", user);
//        return httpResult;
//        
//    }
//    
//    /**
//     * 竞猜/投注 支付成功页
//     * 
//     * @return
//     */
//    @RequestMapping(value = "/result", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    public @ResponseBody HttpResult result(@Secure User user,
//                                           @RequestParam("orderId") Long orderId, HttpServletRequest request) {
//        
//        HttpResult httpResult = new HttpResult();
//        
//        SalesOrder salesOrder = salesOrderService.load(SalesOrder.class, orderId);
//        
//        httpResult.success().data("salesOrder", salesOrder)
//                            .data("user", user);
//        
//        if(salesOrder.getType().equals(OrderType.BET)) {
//            httpResult.data("userBet", salesOrder.getUserBet())
//                      .data("bet", salesOrder.getUserBet().getBet());
//        } else {
//            httpResult.data("userBetSupport", salesOrder.getUserBetSupport())
//                      .data("bet", salesOrder.getUserBetSupport().getBet())
//                      .data("userBet", salesOrder.getUserBetSupport().getUserBet());
//        }
//        return httpResult;
//        
//    }
//
//}
